from django.db import models
#from django.contrib.auth import user

# Create your models here.
class Project (models.Model):
    sponsor = models.CharField(max_length=100)
    name = models.CharField(max_length=130)
    pm_name = models.CharField(max_length=30)
    deputy_pm = models.CharField(max_length=30)
    task_order = models.CharField(max_length=128) 
    prime_contractor = models.CharField(max_length=128)
    project_type = models.CharField(max_length=10)
    team_email = models.EmailField()
    description = models.CharField(max_length=130)
     
    """possible contracting types for each project"""
    CONTRACT_TYPES = (
                      (1, 'Fixed Price'),
                      (2, 'Cost Plus Fees'),
                      (3, 'Time and Material'),
                      (4, 'IDIQ'),
                      ) 
    contract_type = models.IntegerField(max_length=1, null=True, choices=CONTRACT_TYPES)
   
    start_date = models.DateTimeField('Date Started')
    end_date = models.DateTimeField('Date Completed')
    def __str__(self):
        rep = "Project - " + self.name
        return rep

class TemplateModel (models.Model):
    category = models.CharField(max_length=30)
    
#instance of a template Model, a filled out, running template
class Template (models.Model):
    template_model = models.ForeignKey(TemplateModel)
    name = models.CharField(max_length=30)
    file_location = models.CharField(max_length=128)
    project_type = models.CharField(max_length=10)
    
    """possible contracting types for each project"""
    TEMPlATE_TYPES = (
                      (1, 'INTERNAL'),
                      (2, 'EXTERNAL'),
                      ) 
    
class StatusReport (models.Model):
    project = models.ForeignKey(Project)
    template = models.ForeignKey(Template)
    
    period_fdate = models.DateTimeField('Performance Period Started')
    period_tdate = models.DateTimeField('Performance Period Ended')
    
    creation_date = models.DateTimeField('Date Created')
    
    consolidation_date = models.DateTimeField('Date Consolidated', null=True)
    
    filing_date = models.DateTimeField('Date Filed', null=True)
    
    REPORT_TYPES = (
                    (1, 'WEEKLY'),
                    (2, 'BI-WEEKLY'),
                    (3, 'MONTHLY'),
                    (4, 'QUARTERLY'),
                    )
    
    STORE_TYPES = (
		 (1, 'SharePoint', ''),
		 (2, 'Documentum', ''),
		 (3, 'Other ECM', ''),
		 (4, 'File Share', ''),
		 )
     
#not element in template but running element instance, folder    
class ReportElement (models.Model):
    parent_element = models.ForeignKey('self', default=None, null=True, blank=True)
    #root_element =  models.ForeignKey(RootReportElement, default=None, null=True, blank=True)
    #parent_element =
    status_report = models.ForeignKey(StatusReport)
    name = models.CharField(max_length=128)
    description = models.CharField(max_length=128)
    def __str__(self):
        rep = "" + self.description
        return rep    
    
class Entry(models.Model):
    element = models.ForeignKey(ReportElement, null=True)
    content = models.TextField(max_length=256, null=True)
    comment = models.TextField(max_length=256, null=True)
    #author = models.ForeignKey(User)
    on_date = models.DateTimeField('Date updated', null=True)
    status = models.TextField(max_length=56, null=True)
